<template>
  <div class="HelloWorld">
    <div class="Switch-Button">
      <el-button type="primary" @click="lastWeek" link>上周 </el-button>
      <el-button type="primary" @click="thisWeek" link>本周 </el-button>
      <el-button type="primary" @click="nextWeek" link>下周 </el-button>
    </div>
    <div class="weekly">
      <weekly-schedule
        :DateVal="DateVal"
        :DataVal="DataVal"
        @reserve="reserve"
        @addSchedules="addSchedules"
        style="height: 100%"
      >
        <template #Title>排班表</template>
      </weekly-schedule>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import weeklySchedule from "@/components/WeeklySchedule";

//日期
const DateVal = ref(new Date());
//数据
const DataVal = ref([
  {
    name: "陈雅婷",
    MondayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    TuesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    WednesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    ThursdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    FridayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SaturdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SundayData: [],
  },
  {
    name: "李明辉",
    MondayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    TuesdayData: [],
    WednesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    ThursdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    FridayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SaturdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SundayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
  },
  {
    name: "张婉如",
    MondayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    TuesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    WednesdayData: [],
    ThursdayData: [],
    FridayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SaturdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SundayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
  },
  {
    name: "刘志豪",
    MondayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    TuesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    WednesdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    ThursdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    FridayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SaturdayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
    SundayData: [
      {
        scheduleClassesName: "下午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
      {
        scheduleClassesName: "上午班",
        serviceConfigs: [
          {
            scheduleServiceName: "图文咨询",
          },
          {
            scheduleServiceName: "电话问诊",
          },
          {
            scheduleServiceName: "图文咨询",
          },
        ],
      },
    ],
  },
  {
    name: "刘雅琳",
    MondayData: [],
    TuesdayData: [],
    WednesdayData: [],
    ThursdayData: [],
    FridayData: [],
    SaturdayData: [],
    SundayData: [],
  },
]);

function reserve(item, index, week) {
  console.log("reserve", item, index, week);
}

function addSchedules(item, index, week) {
  console.log("addSchedules", item, index, week);
}

function lastWeek() {
  console.log(111);
  let currentDate = new Date(DateVal.value);
  // 获取当前日期的“日”部分，并减去7
  let daysInMonth = currentDate.getDate() - 7;
  // 创建一个新的Date对象，日期设置为计算后的日期，月份和年份保持不变
  // 但由于我们直接修改了“日”部分，如果结果小于1（即上个月的日期），则Date对象会自动处理
  let sevenDaysAgo = new Date(
    currentDate.getFullYear(),
    currentDate.getMonth(),
    daysInMonth
  );
  DateVal.value = sevenDaysAgo;
}

function thisWeek() {
  DateVal.value = new Date();
}

function nextWeek() {
  let currentDate = new Date(DateVal.value);
  let daysInMonth = currentDate.getDate() + 7;
  let sevenDaysAgo = new Date(
    currentDate.getFullYear(),
    currentDate.getMonth(),
    daysInMonth
  );
  DateVal.value = sevenDaysAgo;
}
</script>

<style scoped lang="scss">
.weekly {
  height: calc(100vh - 150px);
}
.Switch-Button {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
